﻿using System.Windows;

namespace SHomeWorkshop.LunarPresentation.Commands
{
    public partial class Command
    {
        /// <summary>
        /// 切换[矛盾/对立]为矛盾关系。
        /// </summary>
        public static void SwitchToContradiction()
        {
            if (Globals.selectedEditor == null) return;
            if (Globals.selectedEditor.SelectedExpression == null) return;
            if ((Globals.selectedEditor.SelectedExpression is Expressions.LogicContradiction) == false)
            {
                MessageBox.Show("请先选中[矛盾/对立]关系式，然后再执行本操作。",
                    Globals.appName, MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            Expressions.LogicContradiction lc = Globals.selectedEditor.SelectedExpression as Expressions.LogicContradiction;

            ModifingItem mi = new ModifingItem();
            Action action = new Action(lc.ExID, -1, lc.GetType().Name, "IsJustContradict", lc.IsJustContradict.ToString(),
                "true");
            
            lc.IsJustContradict = true;

            mi.Add(action);
            lc.Editor.Do(mi);
        }

        /// <summary>
        /// 切换[矛盾/对立]为对立关系。
        /// </summary>
        public static void SwitchToOpposite()
        {
            if (Globals.selectedEditor == null) return;
            if (Globals.selectedEditor.SelectedExpression == null) return;
            if ((Globals.selectedEditor.SelectedExpression is Expressions.LogicContradiction) == false)
            {
                MessageBox.Show("请先选中[矛盾/对立]关系式，然后再执行本操作。",
                    Globals.appName, MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            Expressions.LogicContradiction lc = Globals.selectedEditor.SelectedExpression as Expressions.LogicContradiction;

            ModifingItem mi = new ModifingItem();
            Action action = new Action(lc.ExID, -1, lc.GetType().Name, "IsJustContradict", lc.IsJustContradict.ToString(),
                "false");

            lc.IsJustContradict = false;

            mi.Add(action);
            lc.Editor.Do(mi);
        }
    }
}
